Skip to content

fix: stop leaving .env.bak plaintext secrets on every deploy - #197

Merged
128na merged 3 commits into
masterfrom
fix/deploy-no-env-backup-file
Aug 25, 2026
Merged

fix: stop leaving .env.bak plaintext secrets on every deploy#197
128na merged 3 commits into
masterfrom
fix/deploy-no-env-backup-file

Conversation

@128na

@128na 128na commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • 認証情報ローテーション作業(chore/records/2026-08-25_credential-rotation-sakura-incident.md)のフォローアップ
  • デプロイ処理の sed -i ".bak" がデプロイの度に平文シークレット入りの.env.bakを残していた(誰も削除しない)ことが判明
  • BSDのsed -i ""(空のバックアップ拡張子)に変更し、バックアップファイル自体を作らないようにした

Test plan

  • 次回のタグリリースでデプロイ後に.env.bakが作られないことを確認

🤖 Generated with Claude Code

128na and others added 3 commits August 26, 2026 00:24
sed -i ".bak" on BSD sed creates a backup file containing the full
.env (including all secrets) on every single deploy, and nothing
ever cleaned it up. Found repeatedly during the credential rotation
following the sakura.ad.jp incident (chore/records/2026-08-25).
Switching to an empty backup suffix (sed -i "") makes BSD sed edit
in place without creating a backup file at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…stead

Code review flagged that changing the backup suffix to "" (an empty
double-quote pair sitting inside already deeply nested ssh/bash -c/sed
quoting) is hard to verify by inspection and risky for future edits.
Revert to the previously-proven ".bak" quoting structure (confirmed
working via .env.bak actually being created on the server) and just
delete the backup file explicitly afterward. Same end result (no
leftover .env.bak), but the intent is now a plain rm -f instead of
relying on BSD sed's empty-suffix semantics threaded through triple
quoting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tViolationException

RawPageFactory and PageFactory both used faker->url() without unique(),
but raw_pages.url and pages.url both have DB-level unique constraints
(raw_pages_url_unique, pages_url_unique). Tests that create multiple
Page/RawPage records in one test (e.g. SearchActionTest) occasionally
collide on the same faker-generated URL and fail with
UniqueConstraintViolationException, unrelated to any application code.

Unrelated to this PR's original change, but needed to get CI green
here since it surfaced on this PR's run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@128na
128na merged commit 57a59fc into master Aug 25, 2026
5 checks passed
@128na
128na deleted the fix/deploy-no-env-backup-file branch August 25, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant